home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
System-Boost
/
Workbench
/
Archive
/
XPK
/
xpk_Source
/
test
/
testNILPack.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-11-15
|
2KB
|
110 lines
#define NAME "testNILPack"
#define DISTRIBUTION "(Freeware) "
#define REVISION "1"
/* Programmheader
Name: testNILPack
Author: SDI
Distribution: Freeware
Description: tests Xpk with NIL argument function
Compileropts: -
Linkeropts: -l xpkmaster amiga
1.0 01.04.97 : first version
1.1 28.11.97 : moved chunk-hook into include file
*/
/* Example to show, that xpkmaster may also pack and unpack into NIL:
useful for speed test only. */
#include <proto/dos.h>
#include <proto/xpkmaster.h>
#include <proto/exec.h>
#include "SDI_defines.h"
#include "chunkfunc.c"
struct Library *XpkBase;
void main(int argc, char **argv)
{
STRPTR obuf = 0;
ULONG fh, err, obuflen = 0, olen = 0;
if(argc != 2)
{
VPrintf("Filename needed\n", 0);
exit(0);
}
if(!(XpkBase = OpenLibrary("xpkmaster.library", 4)))
exit(10);
if(!(fh = Open("NIL:", MODE_NEWFILE)))
{
VPrintf("Could not open fh\n", 0);
CloseLibrary(XpkBase);
exit(10);
}
VPrintf("Testing FH Pack access\n", 0);
if((err = XpkPackTags(
XPK_InName, argv[1],
XPK_OutFH, fh,
XPK_ChunkHook, &chunkhook,
XPK_PackMethod, "NUKE",
TAG_DONE)))
XpkPrintFault(err, "FH Pack try");
VPrintf("Testing Name Pack access\n", 0);
if((err = XpkPackTags(
XPK_InName, argv[1],
XPK_OutName, "NIL:",
XPK_ChunkHook, &chunkhook,
XPK_PackMethod, "NUKE",
TAG_DONE)))
XpkPrintFault(err, "Name Pack try");
VPrintf("Producing packed file\n", 0);
if((err = XpkPackTags(
XPK_InName, argv[1],
XPK_PackMethod, "NUKE",
XPK_GetOutBuf, &obuf,
XPK_GetOutBufLen, &obuflen,
XPK_GetOutLen, &olen,
XPK_ChunkHook, &chunkhook,
TAG_DONE)))
XpkPrintFault(err, "Normal Pack try");
VPrintf("Testing FH Unpack access\n", 0);
if((err = XpkUnpackTags(
XPK_InBuf, obuf,
XPK_InLen, olen,
XPK_OutFH, fh,
XPK_ChunkHook, &chunkhook,
TAG_DONE)))
XpkPrintFault(err, "FH Unpack try");
VPrintf("Testing direct Unpack access\n", 0);
if((err = XpkUnpackTags(
XPK_InBuf, obuf,
XPK_InLen, olen,
XPK_OutName, "NIL:",
XPK_ChunkHook, &chunkhook,
TAG_DONE)))
XpkPrintFault(err, "Name Unpack try");
if(obuf)
FreeMem(obuf, obuflen);
if(!Close(fh))
VPrintf("Could not close fh\n", 0);
CloseLibrary(XpkBase);
}